<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/24
 * Time: 16:15
 */
//后台公共控制器，用来判断是否登录

namespace Controller;

use Model\IndexModel;
use Shop\Controller;

class TooController extends Controller{
    public $model;

    public function __construct()
    {
        //些执行 核心控制器的构造方法
        parent::__construct();
        //判断是否登录
        if(empty($_SESSION[SHOP]['admin'])){
            //跳转到登录
            $this->success("请登录！",'Login','login');
        }
        if($_COOKIE['user']!=false){
            $model=new IndexModel();
            $sql="select * from sh_admin where pass='{$_COOKIE['user']}'";
            $arr=$model->pdo_sel($sql);
            $_SESSION[SHOP]['admin']=$arr;
        }
        $this->model=new IndexModel();

    }

    //退出
    public function tc(){
        unset($_SESSION[SHOP]);
        setcookie('user','',time()-1,'/');
        //直接跳转方法
        $this->redirect('Login','login');
    }
}